package com.lh.Service.Impl;

import com.lh.Service.UserService;
import com.lh.bean.User;
import com.lh.dao.UserDao;
import com.lh.utils.MD5Util;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserDao userDao;
    public User login(String user_name, String user_password) {
        User user = userDao.queryUserByName(user_name);
        //加密
        String s = MD5Util.md5(user_password);
        if (s.equals(user.getUser_password())){

            user.setUser_password(null);

            return user;
        }else {
            return null;
        }
    }

    public boolean register(User user) {
        String user_password = user.getUser_password();
        String s = MD5Util.md5(user_password);
        user.setUser_password(s);
        return userDao.insertUser(user);
    }
}
